import Layer from './layer';
import AMap from './map';
import Measure from './measure';
import Draw from './draw';
import Vector from './vector';
import Overlay from './overlay';

function Map(containerId, mapView, centerCoor, zoom, proj, minZoom, maxZoom) {
    this.map = AMap.init(containerId, mapView, centerCoor, zoom, proj, minZoom, maxZoom);
    this.view = this.map.getView();
    this.layer = new Layer(this.map); //图层方法二次封装
    this.measure = new Measure(this.map); //测量方法
    this.draw = new Draw(this.map); //绘图方法
    this.vector = new Vector(this.map); //矢量绘制方法
    this.overlay = new Overlay(this.map); //矢量绘制方法
}

/**
 * @description: 设置显示中心
 * @param {array} coordinates 中心点经纬度[x,y]
 * @param {int} zoom 缩放级别
 * @param {int} duration 动画时间
 * @return {*}
 */
Map.prototype.panTo = function (data) {
    this.view.animate({
        zoom: data.zoom || this.map.getView().getZoom(),
        center: data.coordinates,
        duration: data.duration || 700
    });
};

export default Map;
